home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C ++ / Frameworks / MacZoop 1.6.5 / Basic Classes / Z Headers / ZWindowManager.h < prev   
Encoding:
C/C++ Source or Header  |  1997-07-14  |  5.6 KB  |  161 lines  |  [TEXT/CWIE]

  1. /*************************************************************************************************
  2. *
  3. *
  4. *            ObjectMacZapp            -- a standard Mac OOP application template
  5. *
  6. *
  7. *
  8. *            ZWindowManager.h        -- desktop class; handles floaters
  9. *
  10. *
  11. *
  12. *
  13. *
  14. *            © 1996, Graham Cox
  15. *
  16. *
  17. *
  18. *
  19. *************************************************************************************************/
  20.  
  21. #pragma once
  22.  
  23. #ifndef __ZWINDOWMANAGER__
  24. #define __ZWINDOWMANAGER__
  25.  
  26. #ifndef __ZOBJECTARRAY__
  27. #include    "ZObjectArray.h"
  28. #endif
  29.  
  30. class    ZWindow;
  31.  
  32.  
  33. // container class definition for window list
  34.  
  35. typedef ZObjectArray<ZWindow>    ZWindowList;
  36.  
  37.  
  38. // window manager class
  39.  
  40. class    ZWindowManager
  41. {
  42.     friend class ZMenuBar;
  43.     
  44. protected:
  45.     
  46.     ZWindowList*    nonFloaters;        // list of non-floating windows
  47.     ZWindowList*    floaters;            // list of floating windows        
  48.     ZWindowList*    wmWindows;            // list of windows in menu
  49.     MenuHandle        wmMenu;                // handle of "Windows" menu if any
  50.     short            wmItemOffset;        // item count of initial number of items in menu
  51.     Point            globalPlaceLoc;        // placement position
  52.  
  53. public:
  54.  
  55.     ZWindowManager();
  56.     virtual    ~ZWindowManager();
  57.     
  58.     virtual void        AddWindow( ZWindow* aWindow );
  59.     virtual void        RemoveWindow( ZWindow* aWindow );
  60.     
  61.     virtual void        HideWindow( ZWindow* aWindow );
  62.     virtual void        ShowWindow( ZWindow* aWindow );
  63.     
  64.     virtual void        SelectWindow( ZWindow* aWindow );
  65.     virtual void        DragWindowOutline( ZWindow* aWindow, Point startPt, const short modifiers );
  66.  
  67.     virtual void        Suspend();
  68.     virtual void        Resume();
  69.     virtual void        Deactivate();
  70.     virtual void        Activate();
  71.     
  72.     virtual ZWindow*    GetTopWindow();
  73.     virtual ZWindow*    GetTopFloater();
  74.     virtual ZWindow*    GetBottomFloater();
  75.     
  76.     virtual Boolean        CheckDialogEvent( EventRecord* theEvent );
  77.     virtual ZWindow*    LocateWindow( const Point globalMouse );
  78.     virtual ZWindow*    GetNthWindow( const long n );
  79.     virtual ZWindow*    GetNthFloater( const long n );
  80.     virtual Boolean        IsDialog( ZWindow* aWindow );
  81.     
  82.     virtual Boolean        GetUniqueUntitledName( Str255 wName );
  83.     virtual void        FloatIdle();
  84.     
  85.     virtual short        CountWindows();
  86.     virtual short        CountFloaters();
  87.     
  88.     virtual void        InitiallyPlace( ZWindow* aWindow );
  89.     
  90. private:
  91.     void                BringBehind( ZWindow* aWindow, ZWindow* behindWindow );
  92.     void                PostActivation( ZWindow* aWindow, Boolean state );    
  93.     void                CalcWindowRgns( ZWindow* aWindow, RgnHandle aRgn );
  94.     void                ShowHideFloater( ZWindow* aFloater, Boolean hide );
  95.     
  96. protected:    // these methods accessible to gMenuBar, but not user's code.
  97.  
  98.     virtual void        SetWindowsMenu( MenuHandle aMenu );
  99.     virtual void        SelectWindowFromMenu( const short itemID );
  100.     void                BuildWindowsMenu();
  101. };
  102.  
  103. // This object is created by the application and installed as the global gWindowManager.
  104. // Windows ask this object to manage their selection, etc instead of calling the Mac's
  105. // window manager directly. This allows us to have floaters in our app. Windows have a
  106. // "isFloater" flag, which is inited automatically by detecting which WDEF is used, though this
  107. // can be forced as needed. The event handler also calls this to manage certain window chores
  108. // like dragging, to make sure the Mac Window Manager is never given the chance to screw things
  109. // up for us.
  110.  
  111. extern    ZWindowManager*        gWindowManager;
  112.  
  113. // WARNING: You must not call high-level mac window-manager calls from your code within MacZoop.
  114. // Calls such as SelectWindow() and DragWindow() in particular will cause problems. FrontWindow()
  115. // must be used with caution, since it does not distinguish between floating and non-floating
  116. // windows. Methods are provided here and in ZApplication that provide the equivalent floater-
  117. // savvy functionality.
  118.  
  119. // ZWindowManager compilation options:
  120.  
  121. // HIG says that all floating windows are peers of one another and thus all show the active
  122. // state regardless of their ordering within their layer. Some programmers may prefer the
  123. // other common behaviour where only one floater is active at a time. To get this latter
  124. // behaviour, comment out the following define and recompile. n.b. windows will still receive
  125. // their activate/deactivate messages- this only affects the window hiliting.
  126.  
  127. #define    _ALL_FLOATERS_ACTIVE
  128.  
  129. // this window manager does not allow activate events to be sent by the mac toolbox, but
  130. // instead calls the event handler directly with the relevant parameters. In most cases, your
  131. // code won't be aware of this, but if you really need to get a "real" activation event, 
  132. // comment in the following define. This makes the window manager post a real activation event
  133. // instead of "faking" one.
  134.  
  135. // #define    _ACTIVATE_EVENTS_ARE_REAL
  136.  
  137. // When a window is picked up by its title bar for dragging, it is first brought to the front
  138. // of its layer (unless the command key is down). This selection can result in a non-updated
  139. // area of the window appearing until the drag is completed, at which point the window is
  140. // refreshed. This is the normal behaviour. However, this window manager object can prevent
  141. // this by forcing the update to occur immediately. This may give better perceived performance,
  142. // since the user won't be waiting for the update to come along later. To get this behaviour,
  143. // comment in the following:
  144.  
  145. #define    _UPDATE_ON_SELECT
  146.  
  147. // Similarly, in the same situation, we select the window before dragging it. This is not what
  148. // DragWindow does- it selects the window after dragging. If you really desire this behaviour
  149. // instead, comment in the following:
  150.  
  151. //#define    _DRAGWINDOW_COMPATIBLE
  152.  
  153.  
  154. // If you are taking advantage of the automatic support for a "WIndows" menu, you might want to
  155. // list the windows alphabetically. The default is to list them in order of creation. To list
  156. // alphabetically, commeny IN the following:
  157.  
  158. // #define    _ALPHABETICAL_WINDOWS_MENU
  159.  
  160.  
  161. #endif